package com.trkj.Sevlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.trkj.liuyan.LiuYan;
import com.trkj.liuyan.LiuYanDAO;

/**
 * Servlet implementation class LiuYanListSevlet
 */
@WebServlet("/list")
public class LiuYanListSevlet extends HttpServlet {
	private LiuYanDAO liuYanDAO=new LiuYanDAO();
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String sort=request.getParameter("tag");
		if(sort==null){
			sort=(String) request.getAttribute("sort");
		}
		List<LiuYan> list = null;
		if(sort==null){
			list= liuYanDAO.queryAlla();
			sort="s";
		}else if(sort.equals("s")){
			list= liuYanDAO.queryAlla();
		}else if(sort.equals("j")){
			list= liuYanDAO.queryAlld();
		}
		
		
		request.setAttribute("sort", sort);
		
		
		request.setAttribute("list", list);
		
		request.getRequestDispatcher("list.jsp").forward(request, response);
		
	}

}
